<admintpl file="header" />
<style>
    .ellipsis3 {overflow: hidden; text-overflow:ellipsis; display: -webkit-box; -webkit-line-clamp: 2;-webkit-box-orient: vertical;}
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:U('Question/AdminQuestion/question_list')}">问题列表</a></li>
        <li class="active"><a href="javascript:;">回答列表</a></li>
    </ul>
    <form class="well form-search" method="post" action="{:U('Question/AdminQuestion/answer_list')}">
        作者 ：
        <input type="text" name="author" style="width: 150px;" value="{$formget.author|default=''}" placeholder="请输入作者...">
        时间 ：
        <input type="text" name="start_time" class="js-datetime" value="{$formget.start_time|default=''}" style="width: 120px;" autocomplete="off">-
        <input type="text" class="js-datetime" name="end_time" value="{$formget.end_time|default=''}" style="width: 120px;" autocomplete="off"> &nbsp; &nbsp;
        状态 ：
        <php>
            $status_all = $formget['status'] == -1 ? "selected" : "";
            $status_new = $formget['status'] == 0 ? "selected" : "";
            $status_yes = $formget['status'] == 1 ? "selected" : "";
            $status_no  = $formget['status'] == 2 ? "selected" : "";
        </php>
        <select name="status">
            <option value="-1" {$status_all}>全部</option>
            <option value="0" {$status_new}>新回答</option>
            <option value="1" {$status_yes}>已通过</option>
            <option value="2" {$status_no}>未通过</option>
        </select>
        <input type="submit" class="btn btn-primary" value="搜索" />
        <a class="btn btn-danger" href="{:U('Question/AdminQuestion/answer_list')}">清空</a>
    </form>

    <table class="table table-hover table-bordered table-list">
        <thead>
        <tr>
            <th width="50">排序</th>
            <th width="50">ID</th>
            <th>回答</th>
            <th width="80">作者</th>
            <th width="100">回答时间</th>
            <th width="50">状态</th>
            <th width="70">操作</th>
        </tr>
        </thead>
        <foreach name="questions" item="vo">
            <tr>
                <td><input data-id="{$vo.id}" class="input input-order" type="text" size="5" value="{$vo.post_order}"></td>
                <td>{$vo.id}</td>

                <php>
                    $short_answer = strip_tags($vo['post_content']);
                </php>
                <td>
                    <p class="ellipsis3">{$short_answer}</p>
                    <p style="background-color: #ffffe9; display: inline-block">问题标题 ： {$vo.question_title}</p>
                </td>

                <td>{$vo.user_nicename}</td>
                <td>{:date('Y-m-d H:i',strtotime($vo['post_date']))}</td>
                <td>
                    <php>$status = array('0' => '未审核', '1' => '正常', '2' => '审核未通过')</php>
                    {$status[$vo['post_status']]}
                </td>
                <td>
                    <a href="{:U('AdminQuestion/edit_answer', array('id' => $vo['id']))}">编辑</a>
                </td>
            </tr>
        </foreach>
    </table>
    <div class="pagination">{$page}</div>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script>
    $(document).ready(function () {
        $('body').delegate('.input-order', 'change', function () {
            var order   = $(this).val();
            var id      = $(this).attr('data-id');
            $.get("{:U('Portal/AdminPost/change_post_order')}", {id : id, order : order}, function (data) {
                if (data.status) {
                    window.location.reload();
                }
            })
        })
    })
</script>
</body>
</html>